package com.example.myapplication.navigation

import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.material3.BottomAppBar
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.painterResource
import androidx.navigation.NavHostController


@Composable
fun AppBottomBarM3(selectedDestination : String,navigationToTopLevelDesination : (AppDestination)->Unit,bottomBarState : MutableState<Boolean>){
    AnimatedVisibility(
        visible = bottomBarState.value,
        enter = slideInVertically(initialOffsetY = {it}),
        exit = slideOutVertically(targetOffsetY = {it}),
        content = {
            BottomAppBar {
                NavigationBar {
                    TOP_LEVEL_DESTINATIONS.forEachIndexed { index,item ->
                        NavigationBarItem(
                            icon = { Icon(painter = painterResource(item.selectIcon!!), contentDescription = item.route) },
                            selected = selectedDestination == item.route,
                            onClick = {
                                navigationToTopLevelDesination(item)
                            }
                        )
                    }
                }
            }
        }
    )
}